package com.ss.android.article.base.feature.app.browser;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.text.TextUtils;
import android.view.View;

import com.ss.android.article.browser.R;
import com.ss.android.article.share.d.e;
import com.ss.android.article.share.entity.ShareAction;
import com.ss.android.article.share.entity.ShareImageBean;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.image.FrescoUtils;

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;

final class b implements com.ss.android.article.share.e.b {
    private final GetEntryItemHelper a;

    b(GetEntryItemHelper arg1) {
        this.a = arg1;

    }

    private void a(String arg9) {
        long v4 = 0;
        if (!android.support.design.a.isTextEmpty(arg9)) {
            MobClickCombiner.onEvent(this.a.getContext(), "wap_share", arg9, v4, v4);
        }
    }

    public final boolean a(com.ss.android.article.share.entity.a arg6, View arg7, com.ss.android.article.share.c.a arg8) {
        ShareAction v1;
        ShareAction v0 = null;
        switch (arg6.e) {
            case 1: {
                this.a("share_weixin_moments");
                v1 = ShareAction.wxtimeline;
                break;
            }
            case 2: {
                this.a("share_weixin");
                v1 = ShareAction.wx;
                break;
            }
            case 3: {
                this.a("share_qq");
                v1 = ShareAction.qq;
                break;
            }
            case 4: {
                this.a("share_qzone");
                v1 = ShareAction.qzone;
                break;
            }
            case 10: {
                this.a("share_system");
                v1 = ShareAction.link;
                break;
            }
            case 11: {
                this.a("share_content");
                v1 = ShareAction.text;
                break;
            }
            default: {
                v1 = v0;
                break;
            }
        }

        if (v1 != null) {
            if (v1.equals(ShareAction.link)) {
                String v0_1 = "";
                if (!TextUtils.isEmpty(this.a.d.getTitle())) {
                    v0_1 = v0_1 + this.a.d.getTitle();
                }

                if ((TextUtils.isEmpty(this.a.d.getText())) || (TextUtils.isEmpty(this.a.d.getTargetUrl()))) {
                    if (!TextUtils.isEmpty(this.a.d.getText())) {
                        v0_1 = v0_1 + " " + this.a.d.getText();
                    }

                    if (TextUtils.isEmpty(this.a.d.getTargetUrl())) {
//                        goto label_50;
                    } else {
                        v0_1 = v0_1 + " " + this.a.d.getTargetUrl();
                    }
                } else if (this.a.d.getTargetUrl().equals(this.a.d.getText())) {
                    v0_1 = v0_1 + " " + this.a.d.getTargetUrl();
                } else {
                    v0_1 = v0_1 + " " + this.a.d.getText() + " " + this.a.d.getTargetUrl();
                }

                label_50:
                new e(this.a.getContext()).a(v1).b(v0_1).a();
            } else {
                if (((v1.equals(ShareAction.wx)) || (v1.equals(ShareAction.wxtimeline))) && !FrescoUtils.isCached(Uri.parse(this.a.d.getMedia().getUrl()))) {
                    Bitmap v0_2 = BitmapFactory.decodeResource(this.a.getResources(), R.drawable.a);
                    if (v0_2 != null) {
                        ByteArrayOutputStream v2 = new ByteArrayOutputStream();
                        v0_2.compress(Bitmap.CompressFormat.PNG, 100, ((OutputStream) v2));
                        this.a.d.setMedia(new ShareImageBean(v2.toByteArray()));
                    }
                }

                e v0_3 = new e(this.a.getContext()).a(v1);
                v0_3.a = this.a.d;
                v0_3.a();
            }
        }

        return true;
    }
}

